<template>
  <div class="content">
    <h3 style="text-align: center">已发布内容</h3>
    <el-menu>
      <el-menu-item index="1" @click="ShowItem(1)">
        <i class="el-icon-user"></i>
        <span slot="title">已发布文献</span>
      </el-menu-item>
      <el-menu-item index="2" @click="ShowItem(2)">
        <i class="el-icon-star-on"></i>
        <span slot="title">已发布科研项目</span>
      </el-menu-item>
        <el-menu-item index="3" @click="ShowItem(3)">
        <i class="el-icon-s-cooperation"></i>
        <span slot="title">前往发布</span>
      </el-menu-item>
      </el-menu-item>
        <el-menu-item index="4" @click="ShowItem(4)">
        <i class="el-icon-s-custom"></i>
        <span slot="title">返回学者主页</span>
      </el-menu-item>
    </el-menu>
  </div>
</template>

<script>
export default {
  name: "launchedchoosepad",
  data(){
    return{
      showitem: '',
    }
  },
  methods:{
    getCookie(name) {
				var value = '; ' + document.cookie
				var parts = value.split('; ' + name + '=')
				if (parts.length === 2) return parts.pop().split(';').shift()
			},
    ShowItem(v){
      this.showitem = v.toString();
      this.$emit("filepadchoice", this.showitem);
      if(v === 2)
      {
        this.displaySCI()
      }
    },
    displaySCI(){
				   const self = this;
      	self.axios({
       			   method: 'post',
       			 url: '/show_research/',
        		 data: {
          		 user_id: this.$store.state.username,
        		},
        	headers: {'X-CSRFToken':
              	this.getCookie('csrftoken')
        	},
      	}).then(res => {
        	console.log(res.data);
        	const obj = res.data;
        	this.SetEssayList(obj.essayCollection);
			this.dataVisible=false
				this.SCIdata=true
        }).catch(err => {
        	console.log(err);
        	this.SetEssayList(this.testlist);
        	this.$message("获取发布活动信息失败")
        })
				
		},
		SetEssayList(list){
      		let i;
      		this.$store.state.essaylist.splice(0, this.$store.state.essaylist.length);
      		for(i = 0; i < list.length; i++){
        	this.$store.state.essaylist.push({telling: list[i].name, actstate: list[i].region, actform: list[i].desc});
      }
  },}

}
</script>

<style scoped>
.content{
  width: 20em;
}
.item {
  margin-top: -1em;
  margin-right: 2em;
}
</style>